package com.ply.flashsalessystem.service.impl;

import com.ply.flashsalessystem.entity.pojo.OrderTime;
import com.ply.flashsalessystem.mapper.OrderTimeMapper;
import com.ply.flashsalessystem.service.OrderTimeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author XiaoPan
 * @since 2022-04-07
 */
@Service
public class OrderTimeServiceImpl extends ServiceImpl<OrderTimeMapper, OrderTime> implements OrderTimeService {
    @Autowired
    OrderTimeMapper orderTimeMapper;

    @Override
    public OrderTime query(Integer orderTimeId) {
        return orderTimeMapper.query(orderTimeId);
    }

    @Override
    public OrderTime updateTime(LocalTime time, Integer orderTimeId) {
        OrderTime query = orderTimeMapper.query(orderTimeId);
        if(orderTimeMapper.updateTime(time, orderTimeId) == 0){
            throw new RuntimeException("修改时间时报");
        }
        query.setTime(time);
        return query;
    }
}
